package com.etc.myblog.ser;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.etc.myblog.biz.ArticleBiz;
import com.etc.myblog.biz.ScolumnBiz;
import com.etc.myblog.entity.Article;
import com.etc.myblog.entity.Scolumn;

public class AdColumnSer extends HttpServlet {

		ScolumnBiz scolBiz = new ScolumnBiz();
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request,response);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		if(request.getParameter("op")!=null && request.getParameter("op")!=""){
			String op = request.getParameter("op");
			int id = Integer.parseInt(request.getParameter("id"));
			System.out.println(op);
			//审核通过
			if(op.equals("ColumnPass")){
				Scolumn sCol = new Scolumn();
				sCol = scolBiz.findById(id);
				sCol.setColumnStatus("审核通过");
				scolBiz.updateStatus(sCol);
				System.out.println(sCol.getColumnStatus());
			}
			else if(op.equals("ColumnNoPass")){
				Scolumn sCol = new Scolumn();
				sCol = scolBiz.findById(id);
				sCol.setColumnStatus("审核不通过");
				scolBiz.updateStatus(sCol);
			}
		}
		request.setAttribute("adminName", "原子为");
		List<Scolumn> list = new ArrayList<Scolumn>();
		list = scolBiz.findNoAdSColumn();
		request.setAttribute("columns", list);
		request.getRequestDispatcher("admin/columnAdmin.jsp").forward(request, response);
	}

}
